import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
    },
    extensions: [".ts", ".vue", ".js", ".jsx", ".tsx"], // 导入时想要省略的扩展名列表。
  },
  server: {
    proxy: {
      "/app-dev": {
        target: "http://syt-api.atguigu.cn", //目标地址
        // pathRewrite: {//重置APi 第一种写法
        //   '^/app-dev': ''
        // },
        // vite => rewrite
        rewrite: (path) => path.replace(/^\/app-dev/, ""),
        changeOrigin: true,
      },
    },
  },
});
